﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        var na_feeds = new Object();
        var na_partyposition = new Object();
        var Curr_ID = 1;
        function set_na_feeds(year) {
            if (!year) { return false; }

            var URL = "https://fusiontables.googleusercontent.com/fusiontables/api/query?sql=";
            var TableID = "1k3ZqEnVxEWvsSLSf6s6h-WkNbfL0oPQa35xi-VM";
            var sSelect = "SELECT+*+FROM+" + TableID;
            var sWhere = "+where+Year=" + year + "+ORDER+BY+Year";
            var sLimit = "+LIMIT+500";
            var sSQLURL = URL + sSelect + sWhere + sLimit;
            var querytail = "&jsonCallback=?";
            var jqxhr = jQuery.get(sSQLURL + querytail, set_na_feeds_handler, "jsonp");
        }
        function set_na_feeds_handler(data) {
            var rowNo = data.table.rows.length;
            if (rowNo <= 0) { return false; }
            var tt = 1;
            for (var i = 0; i < rowNo; i++) {
                na_feeds[data.table.rows[i][0]] = {
                    "ID": data.table.rows[i][0],
                    "Year": data.table.rows[i][1],
                    "District": data.table.rows[i][3],
                    "National Assembly Name": data.table.rows[i][2],
                    "Registered Voters": data.table.rows[i][13],
                    'Male Voters': data.table.rows[i][14],
                    'Female Voters': data.table.rows[i][15],
                    'Urbanisation': data.table.rows[i][16],
                    "Turnout": data.table.rows[i][4],
                    "Population": data.table.rows[i][5],
                    "Gender Blnce Men": data.table.rows[i][17],
                    "Gender Blnce Women": data.table.rows[i][18],
                    "Urban": data.table.rows[i][19],
                    "Rural": data.table.rows[i][20],
                    "WATER": data.table.rows[i][21],
                    "ELECTRICITY": data.table.rows[i][22],
                    "PAKKA": data.table.rows[i][23],
                    "Employment": data.table.rows[i][24],
                    "Major Clans": data.table.rows[i][25],
                    "Winning Party": data.table.rows[i][6],
                    "Winning Candidate": data.table.rows[i][7],
                    "Votes Polled for Winner": data.table.rows[i][8],
                    "Runnerup Party": data.table.rows[i][9],
                    "Runnerup Candidate": data.table.rows[i][10],
                    "Votes Polled for Runnerup": data.table.rows[i][11],
                    "Color Code": data.table.rows[i][12]
                };
            };

        }
    </script>
</head>
<body>
    <input type="button" onclick="set_na_feeds(2008)" value="get data" />
</body>
</html>
